package com.woniuxy.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.woniuxy.dao.ServiceMapper;
import com.woniuxy.pojo.ServiceManager;
import com.woniuxy.service.ServiceService;
import com.woniuxy.util.DataGridView;
import com.woniuxy.vo.ServiceVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
 * @Author: yangsen
 * @Date: 2020/5/12 15:07
 */
@Service
public class ServieServiceImpl implements ServiceService {


    @Autowired
    ServiceMapper serviceMapper;

    @Override
    public boolean newWorkOrder(ServiceManager serviceManager) {
        try {
            serviceMapper.newWorkOrder(serviceManager);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    @Override
    public DataGridView selectServiceByServiceVo(ServiceVo serviceVo) {

        Page<Object> page = PageHelper.startPage(serviceVo.getPage(), serviceVo.getLimit());
        List<ServiceManager> userList = this.serviceMapper.selectServiceByServiceVo(serviceVo);
        return new DataGridView(page.getTotal(), userList);
    }

    @Override
    public List<ServiceManager> selectAllService() {
        return serviceMapper.selectAllService();
    }

    @Override
    public void distributeService(HashMap<String, String> userName) {
        serviceMapper.distributeService(userName);
    }

    @Override
    public List<ServiceManager> selectServiceManagerByName(String name) {
        return serviceMapper.selectServiceManagerByName(name);
    }

    @Override
    public boolean dealService(ServiceManager serviceManager) {

        try {
            serviceMapper.dealService(serviceManager);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }

    }

    @Override
    public boolean resultService(ServiceManager serviceManager) {
        try {
            serviceMapper.resultService(serviceManager);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    @Override
    public boolean  serviceFeedback(ServiceManager serviceManager) {
        try {
            serviceMapper.serviceFeedback(serviceManager);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    @Override
    public List<Integer> serviceType() {
        return serviceMapper.serviceType();
    }


}
